package com.loocup.demo.service;

import com.loocup.demo.dao.TaiTouMapper;
import com.loocup.demo.entity.TaiTou;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author loocup
 * @description
 * @since 2019/1/15
 */
@Service("demoServiceImpl")
public class DemoServiceImpl implements DemoService {

    @Autowired
    private TaiTouMapper taiTouMapper;

    @Override
    public TaiTou select(Long id) {
        return taiTouMapper.selectByPrimaryKey(id);
    }

    @Override
    public String insert() {
        TaiTou taitou = new TaiTou();
        taitou.setCaco(Math.random()*1000 + "0");
        taiTouMapper.insert(taitou);
        return "Success";
    }

//    @Transactional
    @Override
    public String delete(Long id){
        taiTouMapper.deleteByPrimaryKey(id);
        if (1 == 1){
            throw new RuntimeException("hello test");
        }
        return "success";
    }
}
